#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <android/bitmap.h>

typedef struct {
	uint8_t alpha;
	uint8_t red;
	uint8_t green;
	uint8_t blue;
} argb;

#define  LOG_TAG    "imageprocess.c"
#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

JNIEXPORT void JNICALL Java_com_imageprocess_MainActivity_renderBmp(JNIEnv* env,
		jobject obj, jobject bitmap) {
	AndroidBitmapInfo info;
	int ret;
	void * pixel;
	if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
		LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
		return;
	}
	LOGI("Bitmap format is%d",info.format);
//	if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
//	        LOGE("Bitmap format is not RGBA_8888 !");
//	        return;
//	    }
	LOGI("color image :: width is %d; height is %d; stride is %d; format is %d;flags is %d",info.width,info.height,info.stride,info.format,info.flags);
	if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixel)) < 0) {
		return;
	}

	AndroidBitmap_unlockPixels(env,bitmap);
}
